//
//  LayListViewController.m
//  yonghu
//
//  Created by 浪尖渝力 on 2018/1/18.
//  Copyright © 2018年 com.DJS. All rights reserved.
//

#import "LayListViewController.h"
#import "LayListView.h"
@interface LayListViewController ()
@property(nonatomic,strong)LayListView *aView;
@end

@implementation LayListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title=@"法律咨询";
    
    _aView=[LayListView new];
    [self.view addSubview:_aView];
    [_aView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
    }];
    _aView.is_mine=@"0";
    _aView.page=1;
    _aView.tableArr=[NSMutableArray arrayWithCapacity:0];
    [_aView creatView];
    _aView.viewController=self;
    [self loadData];
    _aView.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [_aView.tableView.mj_footer endRefreshing];
        [_aView.tableView.mj_header endRefreshing];
        [_aView.tableArr removeAllObjects];
        _aView.page=1;
        [self loadData];
    }];
}

-(void)loadData{
    NSDictionary *userDic = [NSKeyedUnarchiver unarchiveObjectWithFile:_userModelFile];
    NSString *token=[userDic objectForKey:@"token"];
    NSNumber *waiter_id1=[userDic objectForKey:@"user_id"];
    NSString *user_id=[NSString stringWithFormat:@"%@",waiter_id1];
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:user_id,@"user_id",_aView.is_mine,@"is_mine",[NSString stringWithFormat:@"%d",_aView.page],@"page",@"5",@"pagesize",token,@"token",@"0",@"user_role", nil];
    [ZQTools AFNPostDataUrl:@"user/consult/consult_list" Dict:dic andTableView:nil andViewController:self andSuccessBlock:^(id responseObject) {
        
        [_aView.tableView.mj_footer endRefreshing];
        [_aView.tableView.mj_header endRefreshing];
        
        NSArray *typeArr=responseObject;
        [_aView.tableArr addObjectsFromArray:typeArr];
        [_aView.tableView reloadData];
        if (typeArr.count!=0) {
            _aView.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
                _aView.page+=1;
                [self loadData];
            }];
        }
        else{
            _aView.tableView.mj_footer.hidden=YES;
        }
        
    } anderrorBlock:nil];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}



@end
